﻿using MediatR;
using MES.Server.API.Application.Command.Process_Procedures;
using MES.Server.API.Application.Command.Process_Procedures.ProcessManagement;
using MES.Server.API.Dto.ProcessProceduresDTO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ReturnValue;

namespace MES.Server.API.Controllers
{
    /// <summary>
    /// 工序管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessManagementController : ControllerBase
    {
        private readonly IMediator mediator;
        public ProcessManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取工序管理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<ProcessManagementDTO>> GetProcessManagements([FromQuery]GetProcessManagementCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 新增工序管理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public  Task<ApiResult<int>> CreateProcessManagements([FromBody]CreateProcessManagementCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改工序管理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateProcessManagements(UpdateProcessManagementCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除工序管理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public  Task<ApiResult<int>> DeleteProcessManagements([FromQuery]DeleteProcessManagementCommand request)
        {
            return mediator.Send(request);
        }

    }
}
